﻿using System;
using System.Collections.ObjectModel;
using Achievements;

namespace AchievementSample
{
    /// <summary>
    /// A class to hold the achievements of this Application. Created as a singleton so that SharpSerializer could store it, as it does not serialize static properties.
    /// 
    /// 
    /// </summary>
    public class AppAchievements
    {
        private static AppAchievements _instance;
        private IncrementableAchievement _achievementHungryAchievement;

        private ObservableCollection<Achievement> _allAchievements;

        private ActivityAchievement _closedAppAchievement;
        private TimedAchievement _headerAchievement;

        private ActivityAchievement _pressedAppTitleAchievement;

        /// <summary>
        /// Gets or sets the instance.
        /// </summary>
        /// <value>
        /// The instance.
        /// </value>
        public static AppAchievements Instance
        {
            get { return _instance ?? (_instance = new AppAchievements()); }
            set { _instance = value; }
        }

        /// <summary>
        /// Gets all achievements.
        /// </summary>
        public ObservableCollection<Achievement> AllAchievements
        {
            get
            {
                //add each individual achievement
                return _allAchievements ?? (_allAchievements = new ObservableCollection<Achievement>
                                                                   {
                                                                       ClosedAppAchievement,
                                                                       PressedAppTitleAchievement,
                                                                       AchievementHungryAchievement,
                                                                       HeaderAchievement
                                                                   });
            }
        }

        /// <summary>
        /// Gets or sets the closed app achievement.
        /// </summary>
        /// <value>
        /// The closed app achievement.
        /// </value>
        public ActivityAchievement ClosedAppAchievement
        {
            get
            {
                return _closedAppAchievement ?? (_closedAppAchievement = new ActivityAchievement
                                                                             {
                                                                                 Description = "Closed the app.",
                                                                                 Title =
                                                                                     "I think it's time for me to leave",
                                                                                 IsHidden = false,
                                                                                 SmallImagePath =
                                                                                     "/AchievementSample;component/Images/Small/noun_project_21.png",
                                                                                 LargeImagePath =
                                                                                     "/AchievementSample;component/Images/Big/noun_project_21.png",
                                                                                 AchievementValue = 5,
                                                                             });
            }
            set { _closedAppAchievement = value; }
        }

        /// <summary>
        /// Gets or sets the pressed app title achievement.
        /// </summary>
        /// <value>
        /// The pressed app title achievement.
        /// </value>
        public ActivityAchievement PressedAppTitleAchievement
        {
            get
            {
                return _pressedAppTitleAchievement ?? (_pressedAppTitleAchievement = new ActivityAchievement
                                                                                         {
                                                                                             Description =
                                                                                                 "Pressed the App Title",
                                                                                             Title =
                                                                                                 "I wonder if this does anything?",
                                                                                             IsHidden = false,
                                                                                             SmallImagePath =
                                                                                                 "/AchievementSample;component/Images/Small/noun_project_762.png",
                                                                                             LargeImagePath =
                                                                                                 "/AchievementSample;component/Images/Big/noun_project_762.png",
                                                                                             AchievementValue = 10,
                                                                                         });
            }
            set { _pressedAppTitleAchievement = value; }
        }

        /// <summary>
        /// Gets or sets the achievement hungry achievement.
        /// </summary>
        /// <value>
        /// The achievement hungry achievement.
        /// </value>
        public IncrementableAchievement AchievementHungryAchievement
        {
            get
            {
                return _achievementHungryAchievement ?? (_achievementHungryAchievement = new IncrementableAchievement
                                                                                             {
                                                                                                 Description =
                                                                                                     "Pressed the App Title five times.",
                                                                                                 Title =
                                                                                                     "Achievement Hungry",
                                                                                                 IsHidden = true,
                                                                                                 UnlockAmount = 5,
                                                                                                 SmallImagePath =
                                                                                                     "/AchievementSample;component/Images/Small/noun_project_719.png",
                                                                                                 LargeImagePath =
                                                                                                     "/AchievementSample;component/Images/Big/noun_project_719.png",
                                                                                                 AchievementValue = 20,
                                                                                             });
            }
            set { _achievementHungryAchievement = value; }
        }

        /// <summary>
        /// Gets or sets the header achievement.
        /// </summary>
        /// <value>
        /// The header achievement.
        /// </value>
        public TimedAchievement HeaderAchievement
        {
            get
            {
                return _headerAchievement ?? (_headerAchievement = new TimedAchievement
                                                                       {
                                                                           Description =
                                                                               "Clicked on the locked and unlocked pivot headers within 2 seconds of each other.",
                                                                           Title = "Fast Switchin'",
                                                                           IsHidden = true,
                                                                           AchievementTime = TimeSpan.FromSeconds(2),
                                                                           SmallImagePath =
                                                                               "/AchievementSample;component/Images/Small/noun_project_291.png",
                                                                           LargeImagePath =
                                                                               "/AchievementSample;component/Images/Big/noun_project_291.png",
                                                                           AchievementValue = 20
                                                                       });
            }
            set { _headerAchievement = value; }
        }
    }
}